#include <stdio.h>
#include <stdlib.h>

#define RANDN 72

int gcd (int a, int b) {
	if (b == 0) {
		return a;
	} else {
		return gcd (b, a % b);
	}
}

void pollard (int n, int *t, int pi) {
	pi = 0;
	int i = 1;
	int x1 = RANDN, x2;
	int y = x1;
	int k = 2;
	int d;
	
	while (1) {
		i++;
		x1 = (x1*x1 - 1) % n;
		d = gcd (y - x1, n);
		
		if ((d != 1) && (d != n)) {
			t[pi] = d;
			pi++;
			printf ("%d\n", d);
		} 
		if (i == k) {
			y = x1;
			k *= 2;
		}
	}
	
}

int main() {
	
	int t[100];
	int idx;
	int i;
	
	pollard (100, t, idx);
	
	printf ("pi = %d\n", idx);
	
	for (i = 0; i < idx; i++) {
		printf ("%d ", t[i]);
	}
	
	printf ("\n");

	return 0;
}
